/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.com.ohyessoftware.sigc.infra.manager;


import br.com.ohyessoftware.sigc.infra.negocio.Media;
import br.com.ohyessoftware.sigc.infra.persistencia.ColMedia;
import hibernate.HibernateUtil;
import java.util.List;
import org.hibernate.Session;

/**
 *
 * @author Diego
 */
public class UCManterMediaManager {

    private Session session;

    public void cadastrar(Media media) throws Exception {
        session = HibernateUtil.getSessionFactory().getCurrentSession();
        ColMedia colMedia = new ColMedia(session);
        colMedia.salva(media);
    }

    public void editar(Media media) throws Exception {
        session = HibernateUtil.getSessionFactory().getCurrentSession();
        ColMedia colMedia = new ColMedia(session);
        colMedia.altera(media);
    }

    public void remover(Media media) {
        session = HibernateUtil.getSessionFactory().getCurrentSession();
        ColMedia colMedia = new ColMedia(session);
        colMedia.deleta(media);
    }

    public Media pesquisar(Media media, Session session) {
        ColMedia colMedia = new ColMedia(session);
        return colMedia.buscaPK(media.getCodMedia());
    }

    public List<Media> listar(Session session) {
        ColMedia colMedia = new ColMedia(session);
        return colMedia.buscaTodos();
    }
}
